package cn.fczds.camhelper.rider.controller;

import cn.fczds.camhelper.base.response.JsonResult;
import cn.fczds.camhelper.rider.pojo.vo.RiderDateVO;
import cn.fczds.camhelper.rider.pojo.vo.RiderVO;
import cn.fczds.camhelper.rider.service.RiderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("v1/rider/")
public class RiderController {
    @Autowired
    RiderService riderService;

    @GetMapping("select")
    public JsonResult selectRiderInfo(Long userId) {
        log.debug("userId = {}", userId);
       RiderVO riderVO = riderService.select(userId);
        log.debug("riderVO: {}", riderVO);
       return JsonResult.ok(riderVO);
    }

    @GetMapping("selectDate")
    public JsonResult selectDate(Long userId) {
        log.debug("userId = {}", userId);
        RiderDateVO riderDateVO = riderService.selectDate(userId);
        log.debug("riderVO: {}", riderDateVO);
        return JsonResult.ok(riderDateVO);
    }

    @PostMapping("become")
    public JsonResult becomeRider(Long userId) {
        log.debug("userId={}",userId);
        return JsonResult.ok(riderService.becomeRider(userId));
    }
}
